package cc.cix.hq.common.core.entity.enums;

import lombok.Getter;

/**
 * @author cix
 */
@Getter
public enum DesensitizationType {

    /**
     * 手机号脱敏
     */
    PHONE("phone", "11位手机号", "^(\\d{3})\\d{4}(\\d{4})$", "$1****$2"),
    /**
     * 身份证号脱敏
     */
    ID_CARD("idCard", "16或者18身份证号", "^(\\d{4})\\d{8,10}(\\w{4})$", "$1****$2"),
    /**
     * 银行卡号脱敏
     */
    BANK_CARD("bankCardNo", "银行卡号", "^(\\d{4})\\d*(\\d{4})$", "$1****$2"),
    /**
     * 姓名脱敏
     */
    NAME("name", "真实姓名", "(?<=.{1}).*(?=.{1})", "*"),
    /**
     * 邮箱脱敏
     */
    EMAIL("email", "电子邮箱", "(\\w+)\\w{5}@(\\w+)", "$1***@$2");

    private final String type;
    private final String desc;
    private final String[] regular;

    DesensitizationType(String type, String desc, String... regular) {
        this.type = type;
        this.desc = desc;
        this.regular = regular;
    }

    public String getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    public String[] getRegular() {
        return regular;
    }
}
